
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第 4 章 需求1: Top10 热门品类 · 大数据 bigdata_mallanalyze_atguigu 课堂笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content=" 李振超">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-page-toc-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-solarizedlight.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-change_girls/girls.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="di-5-zhang-xu-qiu-2-top10-remen-pin-lei-zhong-de-top10-session-tong-ji.html" />
    
    
    <link rel="prev" href="../di-3-zhang-xiang-mu-da-jian/33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.atguigu.com/" target="_blank" class="custom-link">联系我们</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        <li class="header">第 1 部分 电商分析系统介绍</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    第 1 章 项目简介
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="../11-xiang-mu-zheng-ti-jie-shao.html">
            
                <a href="../11-xiang-mu-zheng-ti-jie-shao.html">
            
                    
                    1.1 项目整体介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="../12-xiang-mu-zheng-ti-jia-gou.html">
            
                <a href="../12-xiang-mu-zheng-ti-jia-gou.html">
            
                    
                    1.2 项目整体架构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3" data-path="../13-ye-wu-xu-qiu.html">
            
                <a href="../13-ye-wu-xu-qiu.html">
            
                    
                    1.3 数据源分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.4" data-path="../14-xiang-mu-xu-qiu.html">
            
                <a href="../14-xiang-mu-xu-qiu.html">
            
                    
                    1.4 项目需求
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1.html">
            
                <a href="../chapter1.html">
            
                    
                    第 2 章 预备知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../di-3-zhang-xiang-mu-da-jian.html">
            
                <a href="../di-3-zhang-xiang-mu-da-jian.html">
            
                    
                    第 3 章 项目搭建
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../di-3-zhang-xiang-mu-da-jian/31-chuang-jian-fu-gong-cheng.html">
            
                <a href="../di-3-zhang-xiang-mu-da-jian/31-chuang-jian-fu-gong-cheng.html">
            
                    
                    3.1 创建父工程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../di-3-zhang-xiang-mu-da-jian/32-chuang-jian-gong-zuo-zi-mo-kuai.html">
            
                <a href="../di-3-zhang-xiang-mu-da-jian/32-chuang-jian-gong-zuo-zi-mo-kuai.html">
            
                    
                    3.2 创建通用子模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../di-3-zhang-xiang-mu-da-jian/33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.html">
            
                <a href="../di-3-zhang-xiang-mu-da-jian/33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.html">
            
                    
                    3.3 创建模拟数据子模块
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">第 2 部分 电商分析系统需求实现</li>
        
        
    
        <li class="chapter active" data-level="2.1" data-path="di-4-zhang-xu-qiu-1.html">
            
                <a href="di-4-zhang-xu-qiu-1.html">
            
                    
                    第 4 章 需求1: Top10 热门品类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="di-5-zhang-xu-qiu-2-top10-remen-pin-lei-zhong-de-top10-session-tong-ji.html">
            
                <a href="di-5-zhang-xu-qiu-2-top10-remen-pin-lei-zhong-de-top10-session-tong-ji.html">
            
                    
                    第 5 章 需求2: Top10热门品类中的 Top10 活跃 Session 统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="di-6-zhang-xu-qiu-3-dan-ye-mian-tiao-zhuan-lv.html">
            
                <a href="di-6-zhang-xu-qiu-3-dan-ye-mian-tiao-zhuan-lv.html">
            
                    
                    第 6 章 需求3: 页面单条转化率统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="di-7-zhang-xu-qiu-4-ge-qu-yu-re-men-shang-pin-top3.html">
            
                <a href="di-7-zhang-xu-qiu-4-ge-qu-yu-re-men-shang-pin-top3.html">
            
                    
                    第 7 章 需求4: 各区域热门商品 Top3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                <a href="di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                    
                    第 8 章 需求5:  广告黑名单实时统计
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/81-li-xian-xiang-mu-yu-bei-zhi-shi.html">
            
                <a href="di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/81-li-xian-xiang-mu-yu-bei-zhi-shi.html">
            
                    
                    8.1 离线项目预备知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.2" data-path="di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/81-shi-shi-huan-jing-da-jian.html">
            
                <a href="di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/81-shi-shi-huan-jing-da-jian.html">
            
                    
                    8.2 实时环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.3" data-path="di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/82-xu-qiu-5-guang-gao-hei-ming-dan-shi-shi-tong-ji.html">
            
                <a href="di-8-zhang-guang-gao-dian-ji-liang-shi-shi-tong-ji/82-xu-qiu-5-guang-gao-hei-ming-dan-shi-shi-tong-ji.html">
            
                    
                    8.3 需求5: 广告黑名单实时统计
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="di-9-zhang-xu-qiu-6-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                <a href="di-9-zhang-xu-qiu-6-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                    
                    第 9 章 需求6: 广告点击量实时统计 
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="di-10-zhang-xu-qiu-7-mei-tian-mei-di-qu-re-men-guang-gao-top3.html">
            
                <a href="di-10-zhang-xu-qiu-7-mei-tian-mei-di-qu-re-men-guang-gao-top3.html">
            
                    
                    第 10 章 需求7: 每天每地区 热门广告 Top3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="di-11-zhang-xin-zeng-xu-6c423a-zui-jin-1-xiao-shi-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                <a href="di-11-zhang-xin-zeng-xu-6c423a-zui-jin-1-xiao-shi-guang-gao-dian-ji-liang-shi-shi-tong-ji.html">
            
                    
                    第 11 章 新增需求: 最近 1 小时广告点击量实时统计
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >第 4 章 需求1: Top10 热门品类</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7B2C;-4-&#x7AE0;-&#x9700;&#x6C42;1-top10-&#x70ED;&#x95E8;&#x54C1;&#x7C7B;">&#x7B2C; 4 &#x7AE0; &#x9700;&#x6C42;1: Top10 &#x70ED;&#x95E8;&#x54C1;&#x7C7B;</h1>
<h3 id="&#x521B;&#x5EFA;&#x79BB;&#x7EBF;&#x5B50;&#x6A21;&#x5757;">&#x521B;&#x5EFA;&#x79BB;&#x7EBF;&#x5B50;&#x6A21;&#x5757;</h3>
<p>&#x521B;&#x5EFA;&#x5B50;&#x6A21;&#x5757;: <code>sparkmall-offline</code></p>
<h3 id="&#x6DFB;&#x52A0;&#x4F9D;&#x8D56;">&#x6DFB;&#x52A0;&#x4F9D;&#x8D56;</h3>
<pre class="language-"><code class="lang-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependencies</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.atguigu<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>sparkmall-common<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0-SNAPSHOT<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.apache.spark<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>spark-core_2.11<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>=-098
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.apache.spark<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>spark-sql_2.11<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.apache.spark<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>spark-hive_2.11<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependencies</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<h3 id="mysql-&#x6570;&#x636E;&#x5E93;&#x51C6;&#x5907;">mysql &#x6570;&#x636E;&#x5E93;&#x51C6;&#x5907;</h3>
<pre class="language-"><code class="lang-sql"><span class="token comment">-- ----------------------------</span>
<span class="token comment">-- create databse sparkmall</span>
<span class="token comment">-- ----------------------------</span>
<span class="token keyword">drop</span> <span class="token keyword">database</span> <span class="token keyword">if</span> <span class="token keyword">EXISTS</span> sparkmall<span class="token punctuation">;</span>
<span class="token keyword">create</span> <span class="token keyword">database</span> sparkmall <span class="token keyword">DEFAULT</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8 <span class="token keyword">COLLATE</span> utf8_general_ci<span class="token punctuation">;</span>


<span class="token comment">-- ----------------------------</span>
<span class="token comment">-- create table category_top10</span>
<span class="token comment">-- ----------------------------</span>
<span class="token keyword">use</span> sparkmall<span class="token punctuation">;</span>
<span class="token keyword">drop</span> <span class="token keyword">table</span> <span class="token keyword">if</span> <span class="token keyword">exists</span> category_top10<span class="token punctuation">;</span>
<span class="token keyword">create</span> <span class="token keyword">table</span> category_top10 <span class="token punctuation">(</span>
    taskId <span class="token keyword">text</span><span class="token punctuation">,</span>
    category_id <span class="token keyword">text</span><span class="token punctuation">,</span>
    click_count <span class="token keyword">bigint</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span> <span class="token keyword">default</span> <span class="token boolean">null</span><span class="token punctuation">,</span>
    order_count <span class="token keyword">bigint</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span> <span class="token keyword">default</span> <span class="token boolean">null</span><span class="token punctuation">,</span>
    pay_count <span class="token keyword">bigint</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span> <span class="token keyword">default</span> <span class="token boolean">null</span>
<span class="token punctuation">)</span><span class="token keyword">ENGINE</span><span class="token operator">=</span><span class="token keyword">InnoDB</span> <span class="token keyword">DEFAULT</span> <span class="token keyword">CHARSET</span><span class="token operator">=</span>utf8<span class="token punctuation">;</span>
</code></pre>
<hr>
<h2 id="41-&#x9700;&#x6C42;1-&#x7B80;&#x4ECB;">4.1 &#x9700;&#x6C42;1: &#x7B80;&#x4ECB;</h2>
<p>&#x54C1;&#x7C7B;&#x662F;&#x6307;&#x7684;&#x4EA7;&#x54C1;&#x7684;&#x7684;&#x5206;&#x7C7B;, &#x4E00;&#x4E9B;&#x7535;&#x5546;&#x54C1;&#x7C7B;&#x5206;&#x591A;&#x7EA7;, &#x54B1;&#x4EEC;&#x7684;&#x9879;&#x76EE;&#x4E2D;&#x54C1;&#x7C7B;&#x7C7B;&#x53EA;&#x6709;&#x4E00;&#x7EA7;.</p>
<p>&#x4E0D;&#x540C;&#x7684;&#x516C;&#x53F8;&#x53EF;&#x80FD;&#x5BF9;&#x70ED;&#x95E8;&#x7684;&#x5B9A;&#x4E49;&#x4E0D;&#x4E00;&#x6837;. </p>
<p>&#x6211;&#x4EEC;&#x6309;&#x7167;&#x6BCF;&#x4E2A;&#x54C1;&#x7C7B;&#x7684; <my>&#x70B9;&#x51FB;&#x3001;&#x4E0B;&#x5355;&#x3001;&#x652F;&#x4ED8;</my> &#x7684;&#x91CF;&#x6765;&#x7EDF;&#x8BA1;&#x70ED;&#x95E8;&#x54C1;&#x7C7B;.</p>
<p>&#x8BA1;&#x7B97;&#x6210;&#x529F;&#x4E4B;&#x540E;, &#x7EDF;&#x8BA1;&#x51FA;&#x6765;&#x7684;&#x6570;&#x636E;&#x5B58;&#x50A8;&#x5230; Mysql &#x4E2D;.</p>
<hr>
<h2 id="42-&#x9700;&#x6C42;1-&#x601D;&#x8DEF;">4.2 &#x9700;&#x6C42;1: &#x601D;&#x8DEF;</h2>
<h3 id="&#x601D;&#x8DEF;1-&#x4F7F;&#x7528;-sql-&#x8BED;&#x53E5;">&#x601D;&#x8DEF;1: &#x4F7F;&#x7528; sql &#x8BED;&#x53E5;</h3>
<p>&#x5206;&#x522B;&#x7EDF;&#x8BA1;&#x6BCF;&#x4E2A;&#x54C1;&#x7C7B;&#x70B9;&#x51FB;&#x7684;&#x6B21;&#x6570;, &#x4E0B;&#x5355;&#x7684;&#x6B21;&#x6570;&#x548C;&#x652F;&#x4ED8;&#x7684;&#x6B21;&#x6570;.</p>
<pre class="language-"><code class="lang-sql"><span class="token number">1.</span> categoryId <span class="token operator">=</span><span class="token operator">&gt;</span> click_count
  <span class="token keyword">select</span> <span class="token function">count</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">where</span> click <span class="token operator">not</span> <span class="token boolean">null</span> <span class="token keyword">group</span> <span class="token keyword">by</span> click_category_id

<span class="token number">2.</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
</code></pre>
<blockquote>
<p>&#x7F3A;&#x70B9;: &#x7EDF;&#x8BA1;&#x4E09;&#x4E2A;&#x6307;&#x6807;&#x5C31;&#x9700;&#x8981;&#x904D;&#x5386;&#x4E09;&#x6B21;&#x6574;&#x8868;, &#x76F8;&#x5F53;&#x8017;&#x65F6;. &#x4E0D;&#x53EF;&#x884C;.</p>
</blockquote>
<h3 id="&#x601D;&#x8DEF;2-&#x904D;&#x5386;&#x4E00;&#x6B21;-&#x7EDF;&#x8BA1;&#x51FA;&#x6765;&#x4E09;&#x4E2A;&#x6307;&#x6807;">&#x601D;&#x8DEF;2: &#x904D;&#x5386;&#x4E00;&#x6B21;, &#x7EDF;&#x8BA1;&#x51FA;&#x6765;&#x4E09;&#x4E2A;&#x6307;&#x6807;</h3>
<p>&#x6211;&#x4EEC;&#x5E94;&#x8BE5;&#x904D;&#x5386;&#x4E00;&#x6B21;&#x6570;&#x636E;, &#x5C31;&#x53EF;&#x4EE5;&#x7EDF;&#x8BA1;&#x51FA;&#x6765;&#x4E09;&#x4E2A;&#x6307;&#x6807;.</p>
<ol>
<li><p>&#x904D;&#x5386;&#x5168;&#x90E8;&#x65E5;&#x5FD7;&#x8868;, &#x6839;&#x636E;&#x54C1;&#x7C7B; id &#x548C;&#x64CD;&#x4F5C;&#x7C7B;&#x578B;&#x5206;&#x522B;&#x7D2F;&#x52A0;. &#x9700;&#x8981;&#x7528;&#x5230;&#x7D2F;&#x52A0;&#x5668;</p>
<ul>
<li>&#x5B9A;&#x4E49;&#x7D2F;&#x52A0;&#x5668;</li>
<li>&#x5F53;&#x78B0;&#x5230;&#x8BA2;&#x5355;&#x548C;&#x652F;&#x4ED8;&#x4E1A;&#x52A1;&#x7684;&#x65F6;&#x5019;&#x6CE8;&#x610F;&#x62C6;&#x5206;&#x5B57;&#x6BB5;&#x624D;&#x80FD;&#x5F97;&#x5230;&#x54C1;&#x7C7B; id</li>
</ul>
</li>
<li><p>&#x904D;&#x5386;&#x5B8C;&#x6210;&#x4E4B;&#x540E;&#x5C31;&#x5F97;&#x5230;&#x6BCF;&#x4E2A;&#x6BCF;&#x4E2A;&#x54C1;&#x7C7B; id &#x548C;&#x64CD;&#x4F5C;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x91CF;.</p>
</li>
<li><p>&#x6309;&#x7167;&#x70B9;&#x51FB;&#x4E0B;&#x5355;&#x652F;&#x4ED8;&#x7684;&#x987A;&#x5E8F;&#x6765;&#x6392;&#x5E8F;</p>
</li>
<li><p>&#x53D6;&#x51FA; Top10</p>
</li>
<li><p>&#x5199;&#x5165;&#x5230; Mysql &#x6570;&#x636E;&#x5E93;</p>
</li>
</ol>
<p><img src="http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/1551946121.png-atguiguText" alt=""></p>
<hr>
<h2 id="43-&#x9700;&#x6C42;1-&#x5177;&#x4F53;&#x5B9E;&#x73B0;">4.3 &#x9700;&#x6C42;1: &#x5177;&#x4F53;&#x5B9E;&#x73B0;</h2>
<h3 id="1-&#x5DE5;&#x5177;&#x7C7B;">1. &#x5DE5;&#x5177;&#x7C7B;</h3>
<h4 id="jdbcutilscala"><code>JDBCUtil.scala</code></h4>
<p>&#x8FD9;&#x4E2A;&#x7C7B;&#x653E;&#x5728;<code>sparkmall-common</code> &#x6A21;&#x5757;&#x4E0B;</p>
<pre class="language-"><code class="lang-scala"><span class="token keyword">package</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>common<span class="token punctuation">.</span>util

<span class="token keyword">import</span> java<span class="token punctuation">.</span>util<span class="token punctuation">.</span>Properties

<span class="token keyword">import</span> com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>druid<span class="token punctuation">.</span>pool<span class="token punctuation">.</span>DruidDataSourceFactory

<span class="token keyword">object</span> JDBCUtil <span class="token punctuation">{</span>

    <span class="token keyword">val</span> dataSource <span class="token operator">=</span> initConnection<span class="token punctuation">(</span><span class="token punctuation">)</span>

    <span class="token comment">/**
      * &#x521D;&#x59CB;&#x5316;&#x7684;&#x8FDE;&#x63A5;
      */</span>
    <span class="token keyword">def</span> initConnection<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token keyword">val</span> properties <span class="token operator">=</span> <span class="token keyword">new</span> Properties<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token keyword">val</span> config <span class="token operator">=</span> ConfigurationUtil<span class="token punctuation">(</span><span class="token string">&quot;config.properties&quot;</span><span class="token punctuation">)</span>
        properties<span class="token punctuation">.</span>setProperty<span class="token punctuation">(</span><span class="token string">&quot;driverClassName&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;com.mysql.jdbc.Driver&quot;</span><span class="token punctuation">)</span>
        properties<span class="token punctuation">.</span>setProperty<span class="token punctuation">(</span><span class="token string">&quot;url&quot;</span><span class="token punctuation">,</span> config<span class="token punctuation">.</span>getString<span class="token punctuation">(</span><span class="token string">&quot;jdbc.url&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
        properties<span class="token punctuation">.</span>setProperty<span class="token punctuation">(</span><span class="token string">&quot;username&quot;</span><span class="token punctuation">,</span> config<span class="token punctuation">.</span>getString<span class="token punctuation">(</span><span class="token string">&quot;jdbc.user&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
        properties<span class="token punctuation">.</span>setProperty<span class="token punctuation">(</span><span class="token string">&quot;password&quot;</span><span class="token punctuation">,</span> config<span class="token punctuation">.</span>getString<span class="token punctuation">(</span><span class="token string">&quot;jdbc.password&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
        properties<span class="token punctuation">.</span>setProperty<span class="token punctuation">(</span><span class="token string">&quot;maxActive&quot;</span><span class="token punctuation">,</span> config<span class="token punctuation">.</span>getString<span class="token punctuation">(</span><span class="token string">&quot;jdbc.maxActive&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
        DruidDataSourceFactory<span class="token punctuation">.</span>createDataSource<span class="token punctuation">(</span>properties<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token comment">/**
      * &#x6267;&#x884C;&#x5355;&#x6761;&#x8BED;&#x53E5;
      *
      * &quot;insert into xxx values (?,?,?)&quot;
      */</span>
    <span class="token keyword">def</span> executeUpdate<span class="token punctuation">(</span>sql<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span> args<span class="token operator">:</span> Array<span class="token punctuation">[</span><span class="token builtin">Any</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token keyword">val</span> conn <span class="token operator">=</span> dataSource<span class="token punctuation">.</span>getConnection
        conn<span class="token punctuation">.</span>setAutoCommit<span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span>
        <span class="token keyword">val</span> ps <span class="token operator">=</span> conn<span class="token punctuation">.</span>prepareStatement<span class="token punctuation">(</span>sql<span class="token punctuation">)</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>args <span class="token operator">!=</span> <span class="token keyword">null</span> <span class="token operator">&amp;&amp;</span> args<span class="token punctuation">.</span>length <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token punctuation">(</span><span class="token number">0</span> until args<span class="token punctuation">.</span>length<span class="token punctuation">)</span><span class="token punctuation">.</span>foreach <span class="token punctuation">{</span>
                i <span class="token keyword">=&gt;</span> ps<span class="token punctuation">.</span>setObject<span class="token punctuation">(</span>i <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> args<span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        ps<span class="token punctuation">.</span>executeUpdate
        conn<span class="token punctuation">.</span>commit<span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>

    <span class="token comment">/**
      * &#x6267;&#x884C;&#x6279;&#x5904;&#x7406;
      */</span>
    <span class="token keyword">def</span> executeBatchUpdate<span class="token punctuation">(</span>sql<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span> argsList<span class="token operator">:</span> Iterable<span class="token punctuation">[</span>Array<span class="token punctuation">[</span><span class="token builtin">Any</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token keyword">val</span> conn <span class="token operator">=</span> dataSource<span class="token punctuation">.</span>getConnection
        conn<span class="token punctuation">.</span>setAutoCommit<span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span>
        <span class="token keyword">val</span> ps <span class="token operator">=</span> conn<span class="token punctuation">.</span>prepareStatement<span class="token punctuation">(</span>sql<span class="token punctuation">)</span>
        argsList<span class="token punctuation">.</span>foreach <span class="token punctuation">{</span>
            <span class="token keyword">case</span> args<span class="token operator">:</span> Array<span class="token punctuation">[</span><span class="token builtin">Any</span><span class="token punctuation">]</span> <span class="token keyword">=&gt;</span> <span class="token punctuation">{</span>
                <span class="token punctuation">(</span><span class="token number">0</span> until args<span class="token punctuation">.</span>length<span class="token punctuation">)</span><span class="token punctuation">.</span>foreach <span class="token punctuation">{</span>
                    i <span class="token keyword">=&gt;</span> ps<span class="token punctuation">.</span>setObject<span class="token punctuation">(</span>i <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> args<span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">)</span>
                <span class="token punctuation">}</span>
                ps<span class="token punctuation">.</span>addBatch<span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        ps<span class="token punctuation">.</span>executeBatch<span class="token punctuation">(</span><span class="token punctuation">)</span>
        conn<span class="token punctuation">.</span>commit<span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h4 id="&#x5305;&#x5BF9;&#x8C61;-&#x5B9A;&#x4E49;&#x4E86;&#x5224;&#x65AD;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x7684;&#x65B9;&#x6CD5;">&#x5305;&#x5BF9;&#x8C61; &#x5B9A;&#x4E49;&#x4E86;&#x5224;&#x65AD;&#x5B57;&#x7B26;&#x4E32;&#x662F;&#x5426;&#x4E3A;&#x7A7A;&#x7684;&#x65B9;&#x6CD5;</h4>
<pre class="language-"><code class="lang-scala"><span class="token keyword">package</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall

<span class="token keyword">package</span> <span class="token keyword">object</span> offline <span class="token punctuation">{</span>
    <span class="token keyword">def</span> isNotEmpty<span class="token punctuation">(</span>text<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Boolean</span> <span class="token operator">=</span> text <span class="token operator">!=</span> <span class="token keyword">null</span> <span class="token operator">&amp;&amp;</span> text<span class="token punctuation">.</span>length <span class="token operator">==</span> <span class="token number">0</span>

    <span class="token keyword">def</span> isEmpty<span class="token punctuation">(</span>text<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Boolean</span> <span class="token operator">=</span> <span class="token operator">!</span>isNotEmpty<span class="token punctuation">(</span>text<span class="token punctuation">)</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="2-bean-&#x7C7B;">2. bean &#x7C7B;</h3>
<p><code>Condition</code>&#x7528;&#x6765;&#x5C01;&#x88C5;&#x4ECE; hive &#x4E2D;&#x8BFB;&#x6570;&#x636E;&#x65F6;&#x7684;&#x8FC7;&#x6EE4;&#x6761;&#x4EF6;</p>
<pre class="language-"><code class="lang-scala"><span class="token keyword">package</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>offline<span class="token punctuation">.</span>bean

<span class="token keyword">case</span> <span class="token keyword">class</span> Condition<span class="token punctuation">(</span><span class="token keyword">var</span> startDate<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                     <span class="token keyword">var</span> endDate<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                     <span class="token keyword">var</span> startAge<span class="token operator">:</span> <span class="token builtin">Int</span><span class="token punctuation">,</span>
                     <span class="token keyword">var</span> endAge<span class="token operator">:</span> <span class="token builtin">Int</span><span class="token punctuation">,</span>
                     <span class="token keyword">var</span> professionals<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                     <span class="token keyword">var</span> city<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                     <span class="token keyword">var</span> gender<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                     <span class="token keyword">var</span> keywords<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                     <span class="token keyword">var</span> categoryIds<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                     <span class="token keyword">var</span> targetPageFlow<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">)</span>
</code></pre>
<p><code>CategoryCountInfo</code>&#x7528;&#x6765;&#x5C01;&#x88C5;&#x5199;&#x5165; Msyql &#x7684;&#x6570;&#x636E;.</p>
<pre class="language-"><code class="lang-scala"><span class="token keyword">package</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>offline<span class="token punctuation">.</span>bean

<span class="token keyword">case</span> <span class="token keyword">class</span> CategoryCountInfo<span class="token punctuation">(</span>taskId<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                             categoryId<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">,</span>
                             clickCount<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">,</span>
                             orderCount<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">,</span>
                             payCount<span class="token operator">:</span> <span class="token builtin">Long</span><span class="token punctuation">)</span>
</code></pre>
<h3 id="&#x4E1A;&#x52A1;&#x5B9E;&#x73B0;">&#x4E1A;&#x52A1;&#x5B9E;&#x73B0;</h3>
<h4 id="1-&#x6574;&#x4E2A;&#x79BB;&#x7EBF;&#x6A21;&#x5757;&#x7684;&#x5165;&#x53E3;&#x7C7B;">1. &#x6574;&#x4E2A;&#x79BB;&#x7EBF;&#x6A21;&#x5757;&#x7684;&#x5165;&#x53E3;&#x7C7B;</h4>
<p><code>OfflineApp.scala</code></p>
<pre class="language-"><code class="lang-scala"><span class="token keyword">package</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>offline

<span class="token keyword">import</span> java<span class="token punctuation">.</span>util<span class="token punctuation">.</span>UUID

<span class="token keyword">import</span> com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>fastjson<span class="token punctuation">.</span>JSON
<span class="token keyword">import</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>common<span class="token punctuation">.</span>bean<span class="token punctuation">.</span>UserVisitAction
<span class="token keyword">import</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>common<span class="token punctuation">.</span>util<span class="token punctuation">.</span>ConfigurationUtil
<span class="token keyword">import</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>offline<span class="token punctuation">.</span>app<span class="token punctuation">.</span>CategoryTop10App
<span class="token keyword">import</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>offline<span class="token punctuation">.</span>bean<span class="token punctuation">.</span>Condition
<span class="token keyword">import</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>spark<span class="token punctuation">.</span>sql<span class="token punctuation">.</span>SparkSession

<span class="token keyword">object</span> OfflineApp <span class="token punctuation">{</span>
    <span class="token keyword">def</span> main<span class="token punctuation">(</span>args<span class="token operator">:</span> Array<span class="token punctuation">[</span><span class="token builtin">String</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Unit</span> <span class="token operator">=</span> <span class="token punctuation">{</span>


        <span class="token keyword">val</span> spark<span class="token operator">:</span> SparkSession <span class="token operator">=</span> SparkSession
            <span class="token punctuation">.</span>builder<span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span>master<span class="token punctuation">(</span><span class="token string">&quot;local[*]&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span>appName<span class="token punctuation">(</span><span class="token string">&quot;OfflineApp&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span>enableHiveSupport<span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span>config<span class="token punctuation">(</span><span class="token string">&quot;spark.sql.warehouse.dir&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;hdfs://hadoop201:9000/user/hive/warehouse&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span>getOrCreate<span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token keyword">val</span> taskId <span class="token operator">=</span> UUID<span class="token punctuation">.</span>randomUUID<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>toString
        <span class="token comment">// &#x6839;&#x636E;&#x6761;&#x4EF6;&#x8FC7;&#x6EE4;&#x53D6;&#x51FA;&#x9700;&#x8981;&#x7684; RDD, &#x8FC7;&#x6EE4;&#x6761;&#x4EF6;&#x5B9A;&#x4E49;&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;</span>
        <span class="token keyword">val</span> userVisitActionRDD <span class="token operator">=</span> readUserVisitActionRDD<span class="token punctuation">(</span>spark<span class="token punctuation">,</span> readConditions<span class="token punctuation">)</span>


        println<span class="token punctuation">(</span><span class="token string">&quot;&#x4EFB;&#x52A1;1: &#x5F00;&#x59CB;&quot;</span><span class="token punctuation">)</span>
        CategoryTop10App<span class="token punctuation">.</span>statCategoryTop10<span class="token punctuation">(</span>spark<span class="token punctuation">,</span> userVisitActionRDD<span class="token punctuation">,</span> taskId<span class="token punctuation">)</span>
        println<span class="token punctuation">(</span><span class="token string">&quot;&#x4EFB;&#x52A1;1: &#x7ED3;&#x675F;&quot;</span><span class="token punctuation">)</span>

    <span class="token punctuation">}</span>

    <span class="token comment">/**
      * &#x8BFB;&#x53D6;&#x6307;&#x5B9A;&#x6761;&#x4EF6;&#x7684; UserVisitActionRDD
      *
      * @param spark
      * @param condition
      */</span>
    <span class="token keyword">def</span> readUserVisitActionRDD<span class="token punctuation">(</span>spark<span class="token operator">:</span> SparkSession<span class="token punctuation">,</span> condition<span class="token operator">:</span> Condition<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token keyword">var</span> sql <span class="token operator">=</span> s<span class="token string">&quot;select v.* from user_visit_action v join user_info u on v.user_id=u.user_id where 1=1&quot;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>isNotEmpty<span class="token punctuation">(</span>condition<span class="token punctuation">.</span>startDate<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            sql <span class="token operator">+=</span> s<span class="token string">&quot; and v.date&gt;=&apos;${condition.startDate}&apos;&quot;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>isNotEmpty<span class="token punctuation">(</span>condition<span class="token punctuation">.</span>endDate<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            sql <span class="token operator">+=</span> s<span class="token string">&quot; and v.date&lt;=&apos;${condition.endDate}&apos;&quot;</span>
        <span class="token punctuation">}</span>

        <span class="token keyword">if</span> <span class="token punctuation">(</span>condition<span class="token punctuation">.</span>startAge <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            sql <span class="token operator">+=</span> s<span class="token string">&quot; and u.age&gt;=${condition.startAge}&quot;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>condition<span class="token punctuation">.</span>endAge <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            sql <span class="token operator">+=</span> s<span class="token string">&quot; and u.age&lt;=${condition.endAge}&quot;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">import</span> spark<span class="token punctuation">.</span>implicits<span class="token punctuation">.</span>_
        spark<span class="token punctuation">.</span>sql<span class="token punctuation">(</span><span class="token string">&quot;use sparkmall&quot;</span><span class="token punctuation">)</span>
        spark<span class="token punctuation">.</span>sql<span class="token punctuation">(</span>sql<span class="token punctuation">)</span><span class="token punctuation">.</span>as<span class="token punctuation">[</span>UserVisitAction<span class="token punctuation">]</span><span class="token punctuation">.</span>rdd
    <span class="token punctuation">}</span>

    <span class="token comment">/**
      * &#x8BFB;&#x53D6;&#x8FC7;&#x6EE4;&#x6761;&#x4EF6;
      *
      * @return
      */</span>
    <span class="token keyword">def</span> readConditions<span class="token operator">:</span> Condition <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token comment">// &#x8BFB;&#x53D6;&#x914D;&#x7F6E;&#x6587;&#x4EF6;</span>
        <span class="token keyword">val</span> config <span class="token operator">=</span> ConfigurationUtil<span class="token punctuation">(</span><span class="token string">&quot;conditions.properties&quot;</span><span class="token punctuation">)</span>
        <span class="token comment">// &#x8BFB;&#x53D6;&#x5230;&#x5176;&#x4E2D;&#x7684; JSON &#x5B57;&#x7B26;&#x4E32;</span>
        <span class="token keyword">val</span> conditionString <span class="token operator">=</span> config<span class="token punctuation">.</span>getString<span class="token punctuation">(</span><span class="token string">&quot;condition.params.json&quot;</span><span class="token punctuation">)</span>
        <span class="token comment">// &#x89E3;&#x6790;&#x6210; Condition &#x5BF9;&#x8C61;</span>
        JSON<span class="token punctuation">.</span>parseObject<span class="token punctuation">(</span>conditionString<span class="token punctuation">,</span> classOf<span class="token punctuation">[</span>Condition<span class="token punctuation">]</span><span class="token punctuation">)</span>

    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h4 id="2-&#x7528;&#x5230;&#x7684;-map-&#x7D2F;&#x52A0;&#x5668;">2. &#x7528;&#x5230;&#x7684; Map &#x7D2F;&#x52A0;&#x5668;</h4>
<pre class="language-"><code class="lang-scala"><span class="token keyword">package</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>offline<span class="token punctuation">.</span>acc

<span class="token keyword">import</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>spark<span class="token punctuation">.</span>util<span class="token punctuation">.</span>AccumulatorV2

<span class="token keyword">import</span> scala<span class="token punctuation">.</span>collection<span class="token punctuation">.</span>mutable

<span class="token keyword">class</span> MapAccumulator <span class="token keyword">extends</span> AccumulatorV2<span class="token punctuation">[</span><span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mutable<span class="token punctuation">.</span>Map<span class="token punctuation">[</span><span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token builtin">Long</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token punctuation">{</span>
    <span class="token keyword">val</span> map <span class="token operator">=</span> mutable<span class="token punctuation">.</span>Map<span class="token punctuation">[</span><span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token builtin">Long</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token punctuation">)</span>

    <span class="token keyword">override</span> <span class="token keyword">def</span> isZero<span class="token operator">:</span> <span class="token builtin">Boolean</span> <span class="token operator">=</span> map<span class="token punctuation">.</span>isEmpty

    <span class="token keyword">override</span> <span class="token keyword">def</span> copy<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> AccumulatorV2<span class="token punctuation">[</span><span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mutable<span class="token punctuation">.</span>Map<span class="token punctuation">[</span><span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token builtin">Long</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token keyword">val</span> newAcc <span class="token operator">=</span> <span class="token keyword">new</span> MapAccumulator
        map<span class="token punctuation">.</span>synchronized <span class="token punctuation">{</span>
            newAcc<span class="token punctuation">.</span>map <span class="token operator">++</span><span class="token operator">=</span> map
        <span class="token punctuation">}</span>
        newAcc
    <span class="token punctuation">}</span>

    <span class="token keyword">override</span> <span class="token keyword">def</span> reset<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Unit</span> <span class="token operator">=</span> map<span class="token punctuation">.</span>clear


    <span class="token keyword">override</span> <span class="token keyword">def</span> add<span class="token punctuation">(</span>v<span class="token operator">:</span> <span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Unit</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        map<span class="token punctuation">(</span>v<span class="token punctuation">)</span> <span class="token operator">=</span> map<span class="token punctuation">.</span>getOrElseUpdate<span class="token punctuation">(</span>v<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token number">1</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// otherMap: (1, click) -&gt; 20  this: (1, click) -&gt; 10         thisMap: (1,2) -&gt; 30</span>
    <span class="token comment">// otherMap: (1, order) -&gt; 5                                  thisMap: (1,3) -&gt; 5</span>
    <span class="token keyword">override</span> <span class="token keyword">def</span> merge<span class="token punctuation">(</span>other<span class="token operator">:</span> AccumulatorV2<span class="token punctuation">[</span><span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mutable<span class="token punctuation">.</span>Map<span class="token punctuation">[</span><span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token builtin">Long</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">Unit</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token keyword">val</span> otherMap<span class="token operator">:</span> mutable<span class="token punctuation">.</span>Map<span class="token punctuation">[</span><span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token builtin">Long</span><span class="token punctuation">]</span> <span class="token operator">=</span> other<span class="token punctuation">.</span>value
        otherMap<span class="token punctuation">.</span>foreach <span class="token punctuation">{</span>
            kv <span class="token keyword">=&gt;</span> map<span class="token punctuation">.</span>put<span class="token punctuation">(</span>kv<span class="token punctuation">.</span>_1<span class="token punctuation">,</span> map<span class="token punctuation">.</span>getOrElse<span class="token punctuation">(</span>kv<span class="token punctuation">.</span>_1<span class="token punctuation">,</span> <span class="token number">0L</span><span class="token punctuation">)</span> <span class="token operator">+</span> kv<span class="token punctuation">.</span>_2<span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">override</span> <span class="token keyword">def</span> value<span class="token operator">:</span> mutable<span class="token punctuation">.</span>Map<span class="token punctuation">[</span><span class="token punctuation">(</span><span class="token builtin">String</span><span class="token punctuation">,</span> <span class="token builtin">String</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token builtin">Long</span><span class="token punctuation">]</span> <span class="token operator">=</span> map
<span class="token punctuation">}</span>
</code></pre>
<h4 id="3-&#x9700;&#x6C42;1&#x5177;&#x4F53;&#x5B9E;&#x73B0;">3. &#x9700;&#x6C42;1&#x5177;&#x4F53;&#x5B9E;&#x73B0;</h4>
<pre class="language-"><code class="lang-scala"><span class="token keyword">package</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>offline<span class="token punctuation">.</span>app

<span class="token keyword">import</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>common<span class="token punctuation">.</span>bean<span class="token punctuation">.</span>UserVisitAction
<span class="token keyword">import</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>common<span class="token punctuation">.</span>util<span class="token punctuation">.</span>JDBCUtil
<span class="token keyword">import</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>offline<span class="token punctuation">.</span>acc<span class="token punctuation">.</span>MapAccumulator
<span class="token keyword">import</span> com<span class="token punctuation">.</span>atguigu<span class="token punctuation">.</span>sparkmall<span class="token punctuation">.</span>offline<span class="token punctuation">.</span>bean<span class="token punctuation">.</span>CategoryCountInfo
<span class="token keyword">import</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>spark<span class="token punctuation">.</span>rdd<span class="token punctuation">.</span>RDD
<span class="token keyword">import</span> org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>spark<span class="token punctuation">.</span>sql<span class="token punctuation">.</span>SparkSession

<span class="token keyword">object</span> CategoryTop10App <span class="token punctuation">{</span>

    <span class="token comment">// &#x7EDF;&#x8BA1;&#x70ED;&#x95E8;&#x54C1; Top10</span>
    <span class="token keyword">def</span> statCategoryTop10<span class="token punctuation">(</span>spark<span class="token operator">:</span> SparkSession<span class="token punctuation">,</span> userVisitActionRDD<span class="token operator">:</span> RDD<span class="token punctuation">[</span>UserVisitAction<span class="token punctuation">]</span><span class="token punctuation">,</span> taskId<span class="token operator">:</span> <span class="token builtin">String</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">{</span>
        <span class="token comment">// 1. &#x6CE8;&#x518C;&#x7D2F;&#x52A0;&#x5668;</span>
        <span class="token keyword">val</span> acc <span class="token operator">=</span> <span class="token keyword">new</span> MapAccumulator
        spark<span class="token punctuation">.</span>sparkContext<span class="token punctuation">.</span>register<span class="token punctuation">(</span>acc<span class="token punctuation">,</span> <span class="token string">&quot;CategoryActionAcc&quot;</span><span class="token punctuation">)</span>

        <span class="token comment">// 2. &#x904D;&#x5386;&#x65E5;&#x5FD7;</span>
        userVisitActionRDD<span class="token punctuation">.</span>foreach <span class="token punctuation">{</span>
            visitAction <span class="token keyword">=&gt;</span> <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>visitAction<span class="token punctuation">.</span>click_category_id <span class="token operator">!=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    acc<span class="token punctuation">.</span>add<span class="token punctuation">(</span>visitAction<span class="token punctuation">.</span>click_category_id<span class="token punctuation">.</span>toString<span class="token punctuation">,</span> <span class="token string">&quot;click&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>visitAction<span class="token punctuation">.</span>order_category_ids <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    visitAction<span class="token punctuation">.</span>order_category_ids<span class="token punctuation">.</span>split<span class="token punctuation">(</span><span class="token string">&quot;,&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span>foreach <span class="token punctuation">{</span>
                        oid <span class="token keyword">=&gt;</span> acc<span class="token punctuation">.</span>add<span class="token punctuation">(</span>oid<span class="token punctuation">,</span> <span class="token string">&quot;order&quot;</span><span class="token punctuation">)</span>
                    <span class="token punctuation">}</span>
                <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>visitAction<span class="token punctuation">.</span>pay_category_ids <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    visitAction<span class="token punctuation">.</span>pay_category_ids<span class="token punctuation">.</span>split<span class="token punctuation">(</span><span class="token string">&quot;,&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span>foreach <span class="token punctuation">{</span>
                        pid <span class="token keyword">=&gt;</span> acc<span class="token punctuation">.</span>add<span class="token punctuation">(</span>pid<span class="token punctuation">,</span> <span class="token string">&quot;pay&quot;</span><span class="token punctuation">)</span>
                    <span class="token punctuation">}</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// 3. &#x904D;&#x5386;&#x5B8C;&#x6210;&#x4E4B;&#x540E;&#x5C31;&#x5F97;&#x5230;&#x6BCF;&#x4E2A;&#x6BCF;&#x4E2A;&#x54C1;&#x7C7B; id &#x548C;&#x64CD;&#x4F5C;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x91CF;.  &#x7136;&#x540E;&#x6309;&#x7167; CategoryId &#x8FDB;&#x884C;&#x8FDB;&#x884C;&#x5206;&#x7EC4;</span>
        <span class="token keyword">val</span> actionCountByCategoryIdMap <span class="token operator">=</span> acc<span class="token punctuation">.</span>value<span class="token punctuation">.</span>groupBy<span class="token punctuation">(</span>_<span class="token punctuation">.</span>_1<span class="token punctuation">.</span>_1<span class="token punctuation">)</span>

        <span class="token comment">// 4. &#x805A;&#x5408;&#x6210; CategoryCountInfo &#x7C7B;&#x578B;&#x7684;&#x96C6;&#x5408;</span>
        <span class="token keyword">val</span> categoryCountInfoList <span class="token operator">=</span> actionCountByCategoryIdMap<span class="token punctuation">.</span>map <span class="token punctuation">{</span>
            <span class="token keyword">case</span> <span class="token punctuation">(</span>cid<span class="token punctuation">,</span> actionMap<span class="token punctuation">)</span> <span class="token keyword">=&gt;</span> CategoryCountInfo<span class="token punctuation">(</span>
                taskId<span class="token punctuation">,</span>
                cid<span class="token punctuation">,</span>
                actionMap<span class="token punctuation">.</span>getOrElse<span class="token punctuation">(</span><span class="token punctuation">(</span>cid<span class="token punctuation">,</span> <span class="token string">&quot;click&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                actionMap<span class="token punctuation">.</span>getOrElse<span class="token punctuation">(</span><span class="token punctuation">(</span>cid<span class="token punctuation">,</span> <span class="token string">&quot;order&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                actionMap<span class="token punctuation">.</span>getOrElse<span class="token punctuation">(</span><span class="token punctuation">(</span>cid<span class="token punctuation">,</span> <span class="token string">&quot;pay&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>
            <span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token punctuation">.</span>toList

        <span class="token comment">// 5. &#x6309;&#x7167; &#x70B9;&#x51FB; &#x4E0B;&#x5355; &#x652F;&#x4ED8; &#x7684;&#x987A;&#x5E8F;&#x964D;&#x5E8F;&#x6765;&#x6392;&#x5E8F;</span>
        <span class="token keyword">val</span> sortedCategoryInfoList <span class="token operator">=</span> categoryCountInfoList<span class="token punctuation">.</span>sortBy<span class="token punctuation">(</span>info <span class="token keyword">=&gt;</span> <span class="token punctuation">(</span>info<span class="token punctuation">.</span>clickCount<span class="token punctuation">,</span> info<span class="token punctuation">.</span>orderCount<span class="token punctuation">,</span> info<span class="token punctuation">.</span>payCount<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">(</span>Ordering<span class="token punctuation">.</span>Tuple3<span class="token punctuation">(</span>Ordering<span class="token punctuation">.</span><span class="token builtin">Long</span><span class="token punctuation">.</span>reverse<span class="token punctuation">,</span> Ordering<span class="token punctuation">.</span><span class="token builtin">Long</span><span class="token punctuation">.</span>reverse<span class="token punctuation">,</span> Ordering<span class="token punctuation">.</span><span class="token builtin">Long</span><span class="token punctuation">.</span>reverse<span class="token punctuation">)</span><span class="token punctuation">)</span>

        <span class="token comment">// 6. &#x622A;&#x53D6;&#x524D; 10</span>
        <span class="token keyword">val</span> top10 <span class="token operator">=</span> sortedCategoryInfoList<span class="token punctuation">.</span>take<span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span>

        <span class="token comment">// 7. &#x63D2;&#x5165;&#x6570;&#x636E;&#x5E93;</span>
        <span class="token keyword">val</span> argsList <span class="token operator">=</span> top10<span class="token punctuation">.</span>map<span class="token punctuation">(</span>info <span class="token keyword">=&gt;</span> Array<span class="token punctuation">(</span>info<span class="token punctuation">.</span>taskId<span class="token punctuation">,</span> info<span class="token punctuation">.</span>categoryId<span class="token punctuation">,</span> info<span class="token punctuation">.</span>clickCount<span class="token punctuation">,</span> info<span class="token punctuation">.</span>orderCount<span class="token punctuation">,</span> info<span class="token punctuation">.</span>payCount<span class="token punctuation">)</span><span class="token punctuation">)</span>
        JDBCUtil<span class="token punctuation">.</span>executeBatchUpdate<span class="token punctuation">(</span><span class="token string">&quot;insert into category_top10 values(?, ?, ?, ?, ?)&quot;</span><span class="token punctuation">,</span> argsList<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token comment">/*
1. &#x904D;&#x5386;&#x5168;&#x90E8;&#x65E5;&#x5FD7;&#x8868;, &#x6839;&#x636E;&#x54C1;&#x7C7B; id &#x548C;&#x64CD;&#x4F5C;&#x7C7B;&#x578B;&#x5206;&#x522B;&#x7D2F;&#x52A0;. &#x9700;&#x8981;&#x7528;&#x5230;&#x7D2F;&#x52A0;&#x5668;

    - &#x5B9A;&#x4E49;&#x7D2F;&#x52A0;&#x5668;
        &#x7D2F;&#x52A0;&#x5668;&#x7528;&#x4EC0;&#x4E48;&#x6765;&#x4FDD;&#x5B58;? map
         key:  (categoryId, action)    &#x5143;&#x7EC4;&#x6765;&#x8868;&#x793A;
         value: count
    - &#x5F53;&#x78B0;&#x5230;&#x8BA2;&#x5355;&#x548C;&#x652F;&#x4ED8;&#x4E1A;&#x52A1;&#x7684;&#x65F6;&#x5019;&#x6CE8;&#x610F;&#x62C6;&#x5206;&#x5B57;&#x6BB5;&#x624D;&#x80FD;&#x5F97;&#x5230;&#x54C1;&#x7C7B; id

2. &#x904D;&#x5386;&#x5B8C;&#x6210;&#x4E4B;&#x540E;&#x5C31;&#x5F97;&#x5230;&#x6BCF;&#x4E2A;&#x6BCF;&#x4E2A;&#x54C1;&#x7C7B; id &#x548C;&#x64CD;&#x4F5C;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x91CF;. &#x7136;&#x540E;&#x6309;&#x7167; cid &#x8FDB;&#x884C;&#x805A;&#x5408;, &#x805A;&#x5408;&#x6210; CategoryCountInfo &#x7C7B;&#x578B;

3. &#x6309;&#x7167; &#x70B9;&#x51FB; &#x4E0B;&#x5355; &#x652F;&#x4ED8; &#x7684;&#x987A;&#x5E8F;&#x6765;&#x6392;&#x5E8F;

4. &#x53D6;&#x51FA; Top10

5. &#x5199;&#x5165;&#x5230; Mysql &#x6570;&#x636E;&#x5E93;
*/</span>
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; &#x5C1A;&#x7845;&#x8C37;&#x5927;&#x6570;&#x636E; 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification"><br>&#x8BE5;&#x6587;&#x4EF6;&#x6700;&#x540E;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2019-06-15 20:23:47
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../di-3-zhang-xiang-mu-da-jian/33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.html" class="navigation navigation-prev " aria-label="Previous page: 3.3 创建模拟数据子模块">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="di-5-zhang-xu-qiu-2-top10-remen-pin-lei-zhong-de-top10-session-tong-ji.html" class="navigation navigation-next " aria-label="Next page: 第 5 章 需求2: Top10热门品类中的 Top10 活跃 Session 统计">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第 4 章 需求1: Top10 热门品类","level":"2.1","depth":1,"next":{"title":"第 5 章 需求2: Top10热门品类中的 Top10 活跃 Session 统计","level":"2.2","depth":1,"path":"di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-5-zhang-xu-qiu-2-top10-remen-pin-lei-zhong-de-top10-session-tong-ji.md","ref":"di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-5-zhang-xu-qiu-2-top10-remen-pin-lei-zhong-de-top10-session-tong-ji.md","articles":[]},"previous":{"title":"3.3 创建模拟数据子模块","level":"1.3.3","depth":2,"path":"di-3-zhang-xiang-mu-da-jian/33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.md","ref":"di-3-zhang-xiang-mu-da-jian/33-chuang-jian-mo-ni-shu-ju-zi-mo-kuai.md","articles":[]},"dir":"ltr"},"config":{"plugins":["splitter","expandable-chapters-small","page-toc-button","-highlight","prism","prism-themes","tbfed-pagefooter","sitemap","change_girls","livereload"],"styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy 尚硅谷大数据 2019","modify_label":"<br>该文件最后修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prismjs/themes/prism-solarizedlight.css"]},"disqus":{"shortName":"zhenchao125"},"livereload":{},"splitter":{},"change_girls":{"time":30,"urls":["http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/62171757.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/83394736.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/15906185.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/15906185.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/3394270.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/65028582.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/20359261.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/37472401.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/3355397.jpg-atguiguImg","http://lizhenchao.oss-cn-shenzhen.aliyuncs.com/imgs/18-3-4/11075549.jpg-atguiguImg"]},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"sitemap":{"hostname":"http://bigdataatguigu.applinzi.com/"},"page-toc-button":{"maxTocDepth":3,"minTocSize":2},"prism-themes":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":" 李振超","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"大数据 bigdata_mallanalyze_atguigu 课堂笔记","language":"zh-hans","links":{"sidebar":{"联系我们":"http://www.atguigu.com/"}},"gitbook":"*","description":"课堂笔记,学生提前预习"},"file":{"path":"di-2-bu-fen-dian-shang-fen-xi-xi-tong-xu-qiu-shi-xian/di-4-zhang-xu-qiu-1.md","mtime":"2019-06-15T12:23:47.188Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-19T00:04:29.500Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-page-toc-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-change_girls/girls.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

